/******************************************************************************
 *   ObjectFS - Embedded Object File-System
 *
 *   Provides a full, simple no-nonsense file-system for simple embedded devices.
 *   Written by James Walmsley, james@fullfat-fs.co.uk
 *
 *   Copyright 2010 James Walmsley
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 *
 *   Removing the above notice is illegal and will invalidate this license.
 *****************************************************************************/

#include "ofs_types.h"
#include "ofs_config.h"

#ifndef _OFS_MEMORY_H_
#define _OFS_MEMORY_H_

#if defined(OFS_LITTLE_ENDIAN)

typedef struct {
	OFS_UINT8	u8_0;
	OFS_UINT8	u8_1;
} OFS_SHORT;

typedef struct {
	OFS_UINT8	u8_0;
	OFS_UINT8	u8_1;
	OFS_UINT8	u8_2;
	OFS_UINT8	u8_3;
} OFS_LONG;

#elif defined(OFS_BIG_ENDIAN)

typedef struct {
	OFS_UINT8	u8_1;
	OFS_UINT6	u8_0;
} OFS_SHORT;

typedef struct {
	OFS_UINT8	u8_3;
	OFS_UINT8	u8_2;
	OFS_UINT8	u8_1;
	OFS_UINT8	u8_0;
} OFS_LONG;

#else
#error "Please select an endianess in ofs_config.h file".
#endif

typedef union {
	OFS_UINT16 	u16;
	OFS_SHORT	bytes;
} OFS_UN16;

typedef union {
	OFS_UINT32 	u32;
	OFS_LONG	bytes;
} OFS_UN32;

OFS_UINT8 	OFS_getChar		(OFS_UINT8 *pBuffer, OFS_INT nOffset);
OFS_UINT16 	OFS_getShort	(OFS_UINT8 *pBuffer, OFS_INT nOffset);
OFS_UINT32 	OFS_getLong		(OFS_UINT8 *pBuffer, OFS_INT nOffset);
void		OFS_putChar		(OFS_UINT8 *pBuffer, OFS_INT nOffset, OFS_UINT8 Value);
void		OFS_putShort	(OFS_UINT8 *pBuffer, OFS_INT nOffset, OFS_UINT16 Value);
void		OFS_putLong		(OFS_UINT8 *pBuffer, OFS_INT nOffset, OFS_UINT32 Value);

#endif
